package com.sky.mapper;

import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface ShoppingCartMapper {

    /**
     * 查询购物车
     *
 * @param shoppingCart
     * @return
     * @author heiheiheng
     * @create 2025/8/8
     **/
    ShoppingCart List(ShoppingCart shoppingCart);

    /**
     * 插入一条购物车数据
     * 
 * @param shoppingCart
     * @return 
     * @author heiheiheng
     * @create 2025/8/8
     **/
    @Insert("insert into shopping_cart(name,user_id,dish_id,setmeal_id,dish_flavor,number,amount,image,create_time)"+
    "values (#{name},#{userId},#{dishId},#{setmealId},#{dishFlavor},#{number},#{amount},#{image},#{createTime})")
    void insert(ShoppingCart shoppingCart);

    /**
     * 根据id修改商品数量
     * @param shoppingCart
     */
    @Update("update shopping_cart set number=#{number},amount=#{amount} where id=#{id}")
    void update(ShoppingCart shoppingCart);

    @Select("select * from shopping_cart where user_id = #{userId}")
    List<ShoppingCart> selectList(Long userId);

    /**
     * 清空购物车
     * 
 * @param shoppingCart
     * @return 
     * @author heiheiheng
     * @create 2025/8/8
     **/
    void delete(ShoppingCart shoppingCart);

    /**
     * 批量插入购物车
     *
 * @param list
     * @return
     * @author heiheiheng
     * @create 2025/8/11
     **/
    void insertBatch(List<ShoppingCart> list);
}
